import Mock from 'mockjs'
const category = Mock.mock({
    'list|10': [{
        "id|+1": 1,
        "categoryName": "仓库分类@id"
    }]
})
const warehouse = Mock.mock({
    'list|30': [{
        "id|+1": 1,
        "wareName": "仓库@id",
        "wareCode": "000@id",
        "address": "仓库地址@id",
        "category": "仓库分类@id",
        "categoryId": "@id",
        "isFull": "",
        "chagerId": "",
        "districtCode": "",
        "districtName": "",
        "IocCode": "",
        "IocName": "",
        "strayCode": "",
        "maxQty": "",
        "usedQty": "",
        "remark": ""
    }]
})
export default [

    // 商品分类
    {
        url: '/warehouse/category/getAll',
        type: 'post',
        response: config => {
            return {
                code: 20000,
                data: category.list
            }
        }
    },
    //获取商品信息列表
    {
        url: '/warehouse/getPageList',
        type: 'post',
        response: config => {
            let { pageSize = 10, currentPage = 1 } = config.body
            const total = warehouse.list.length
            let list = warehouse.list.slice(pageSize * (currentPage - 1), currentPage * pageSize)
            return {
                code: 20000,
                data: {
                    list,
                    currentPage,
                    pageSize,
                    totalCount: total,
                    totalPages: (total + pageSize - 1) / pageSize,
                }
            }
        }
    },
    //删除商品
    {
        url: '/warehouse/del',
        type: 'post',
        response: config => {
            const { id } = config.body
            if (!id) {
                return {
                    code: 403,
                    msg: '删除失败',
                    data: null
                }
            }
            return {
                code: 20000,
                msg: '处理成功',
                data: id
            }
        }
    },
    //新增商品
    {
        url: '/warehouse/add',
        type: 'post',
        response: config => {
            return {
                code: 20000,
                msg: '新增成功',
            }
        }
    },
    //修改商品
    {
        url: '/warehouse/editor',
        type: 'post',
        response: config => {
            return {
                code: 20000,
                msg: '修改成功',
            }
        }
    },
]